home *** CD-ROM | disk | FTP | other *** search
/ Macademic for Students & Teachers / Macademic for Students and Teachers (Quantum Leap)(1992).iso / General Interest / Whole Earth Catalog⁄stack / stack.txt < prev   
Encoding:
Text File  |  1987-09-20  |  9.0 KB  |  263 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x0 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 4
  11. -- first background id: 2761
  12. -- card count: 20
  13. -- first card id: 2944
  14. -- list block id: 2093
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 8
  19. -- free size: 4032 bytes
  20. -- total size: 40960 bytes
  21. -- stack block size: 8192 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x00000000
  24. -- modified by hypercard version: 0x00000000
  25. -- opened by hypercard version: 0x00000000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on idle
  69.   set lockscreen to false
  70. end idle
  71. function getLine fileName
  72. -- read one line from the file
  73. read from file fileName until return
  74. put it into msg
  75. return (it)
  76. end getLine
  77. function terminator thisLine
  78. -- is thisLine a message terminator?
  79. global terminators
  80. if char 1 to 5 of thisLine is "Topic" and char 10 of thisLine is ":" then return true
  81. repeat with i = 1 to number of lines in terminators
  82.   if line i of terminators is in thisLine then return true
  83. end repeat
  84. return false
  85. end terminator
  86. function getNum thisLine
  87. -- crack the leading number from a contents line
  88. put offset(":", thisLine) into endHere
  89. return value(char 1 to endHere - 1 of thisLine)
  90. end getNum
  91. function insertLine theField,thisNum,thisLine
  92. -- figure out where the new line should go in contents
  93. -- blank contents?
  94. if bkgnd field theField is empty then
  95.   put thisLine into bkgnd field theField
  96.   return 1
  97. end if
  98. -- at end? (the most common case - checked first)
  99. if getNum(last line of bkgnd field theField) < thisNum then
  100.   put thisLine after bkgnd field theField
  101.   return number of lines in bkgnd field theField
  102. end if
  103. -- all right, do it the hard way
  104. repeat with i = 1 to number of lines in bkgnd field theField
  105.   if thisNum < getNum(line i of bkgnd field theField) then
  106.     put thisLine before line i of bkgnd field theField
  107.     return i
  108.   end if
  109. end repeat
  110. end insertLine
  111. on addText newText
  112.   -- concatenate to global text object, observing size limit
  113.   global theText, textLength
  114.   add length(newText) to textLength
  115.   if textLength > 29990 then exit addText
  116.   put newText after theText
  117. end addText
  118. function slurpText fileName,discard,putHere
  119. -- skip null lines, build message, paste into card
  120. -- return terminating line for analysis
  121. global theText, textLength
  122. repeat discard
  123.   put getline(fileName) into foo
  124. end repeat
  125. put empty into theText
  126. put 0 into textLength
  127. repeat
  128.   -- pull in the message text
  129.   -- done offscreen for performance reasons (no redraws)
  130.   put getLine(fileName) into theLine
  131.   if terminator(theLine) then exit repeat
  132.   addText theLine
  133. end repeat
  134. put theText into bkgnd field putHere
  135. return theLine
  136. end slurpText
  137. on setID topicID,idLine
  138.   -- put id of this card into hidden link field of topic header card
  139.   if idLine is 0 then exit setID
  140.   get the id of this card
  141.   put it into line idLine of field "theLinks" of card id (word 3 of topicID)
  142. end setID
  143. on import
  144.   -- don't try to understand the details without a WELL transcript!
  145.   global terminators
  146.   ask "Please enter name of text file:"
  147.   if it is empty then exit import
  148.   put it into fileName
  149.   open file fileName
  150.   put "Interrupt!" & return & "(r)espond" & return & "responses total." into terminators
  151.   repeat
  152.     put getLine(fileName) into theLine
  153.     if theLine is empty then exit repeat
  154.     repeat while char 1 to 5 of theLine is "Topic" and char 10 of theLine is ":"
  155.       delete last char of theLine
  156.       delete char 11 of theLine
  157.       delete char 1 to 5 of theLine
  158.       put getNum(theLine) into topicNum
  159.       put topicNum into char 1 to 4 of theLine
  160.       if theLine is not in field "theTopics" of card "Conference" then
  161.         -- There is no Topic line in the Conference card
  162.         go to card "Conference"
  163.         put char 1 to 65 of theLine & return into theLine
  164.         put insertLine("theTopics", topicNum, theLine) into foo
  165.       end if
  166.       put theLine into topicLine
  167.       go to card ("Topic" & topicNum) of bkgnd "Topic"
  168.       if the result is not empty then
  169.         -- There is no Topic header card for this topic
  170.         go to card 1 of bkgnd "Topic"
  171.         doMenu Copy Card
  172.         go to last card
  173.         doMenu Paste Card
  174.         set the name of this card to "Topic" & topicNum
  175.         put theLine into bkgnd field "theTopic"
  176.         -- read author line
  177.         put getLine(fileName) into theLine
  178.         if char 1 to 4 of theLine is "By: " then
  179.           -- This is originator's message
  180.           delete char 1 to 4 of theLine
  181.           put offset(")", theLine) into endHere
  182.           put char 1 to endHere of theLine into bkgnd field "theOriginator"
  183.           delete char 1 to endHere + 4 of theLine
  184.           put theLine into bkgnd field "theOriginDate"
  185.           -- skip over responses line & two guaranteed blanks
  186.           put slurpText(fileName,3,"theIntro") into theLine
  187.           next repeat
  188.         end if
  189.       else
  190.         -- read author line
  191.         put getLine(fileName) into theLine
  192.       end if
  193.       -- there is (now) a header card for this Topic
  194.       -- don't repeat existing originator's messages
  195.       if char 1 to 4 of theLine is "By: " then next repeat
  196.       -- look for format errors
  197.       if char 1 of theLine is not "#" or char 5 of theLine is not ":" then next repeat
  198.       -- reformat the line
  199.       delete last char of theLine
  200.       delete first char of theLine
  201.       put getNum(theLine) into responseNum
  202.       delete char 1 to 4 of theLine
  203.       put offset(":", theLine) into endHere
  204.       put char 1 to (endHere + 3) of theLine into theLine
  205.       put responseNum & ":" before theLine
  206.       put 0 into idLine
  207.       -- add this line to topic index?
  208.       if theLine is not in bkgnd field "theResponses" then
  209.         put char 1 to 65 of theLine & return into theLine
  210.         put insertLine("theResponses", responseNum, theLine) into idLine
  211.       else
  212.         repeat with i = 1 to number of lines in bkgnd field "theResponses"
  213.           if line i of bkgnd field "theResponses" is theLine then
  214.             put i into idLine
  215.             exit repeat
  216.           end if
  217.         end repeat
  218.       end if
  219.       put theLine into responseLine
  220.       get the id of bkgnd "Response"
  221.       put it into respID
  222.       get the id of this card
  223.       put it into topicID
  224.       -- go looking for a place for this response
  225.       -- (It would be faster to just use the link from the preceding
  226.       -- contents entry, but things would crash if someone had deleted
  227.       -- the response manually leaving a broken link!)
  228.       set lockscreen to true
  229.       repeat
  230.         go to next card
  231.         get the ID of this bkgnd
  232.         if it is respID then
  233.           -- if number matches, we already have this one
  234.           if bkgnd field "theResponseNum" is responseNum then
  235.             setID topicID,idLine
  236.             exit repeat
  237.           end if
  238.           -- haven't counted far enough, keep going
  239.           if bkgnd field "theResponseNum" < responseNum then next repeat
  240.         end if
  241.         -- either at end of cards for this topic, or found the right place
  242.         go to prev card
  243.         set lockscreen to false
  244.         push card
  245.         go to first card of bkgnd "Response"
  246.         doMenu Copy Card
  247.         pop card
  248.         doMenu Paste Card
  249.         -- fill in the card header
  250.         put topicLine into bkgnd field "theTopic"
  251.         put responseNum into bkgnd field "theResponseNum"
  252.         put responseLine into bkgnd field "theResponseLine"
  253.         put slurpText(fileName,1,"theText") into theLine
  254.         setID topicID,idLine
  255.         exit repeat
  256.       end repeat
  257.       set lockscreen to false
  258.     end repeat
  259.   end repeat
  260.   close file fileName
  261. end import
  262.  
  263.